home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 May
/
EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso
/
softwareupdate
/
system
/
amigados
/
advancedroutines
/
functions.doc
< prev
next >
Wrap
Text File
|
1996-10-10
|
11KB
|
333 lines
7 ADVANCED AMIGADOS ROUTINES - FUNCTIONS
7.1 QUICK REFERENCE
Here is a complete list of all functions described in this
chapter:
Function Description
-------------------------------------------------------------
AllocDosObject() Allocates AmigaDOS objects.
AllocDosObjectTagList() Allocates AmigaDOS objects.
AllocDosObjectTags() Allocates AmigaDOS objects.
Examine() Examines a file, direcotry or volume.
ExNext() Examines objects in a directory.
FreeDosObject() Deallocates AmigaDOS objects.
Info() Examines a disk.
-------------------------------------------------------------
---------------------------------------------------------------
AllocDosObject(), AllocDosObjectTagList(), AllocDosObjectTags()
ROM library: "dos.library/AllocDosObject", (V37+)
#include <clib/dos_protos.h>
Allocates different types of objects used by AmigaDOS. The
objects will be long word aligned, and the size can vary
between different dos library releases.
Synopsis: object = AllocDosObject( type, tags );
object: (APTR) The function will return a pointer to the new
allocated object, or NULL if the object could not be
created.
types: (ULONG) The type of object you want to allocate:
(defined in header file "dos/dos.h")
DOS_FIB FileInfoBlock structure.
DOS_FILEHANDLE When you want to create your own
file handler. Rarely used.
DOS_EXALLCONTROL To create an object used by the
ExAll() function. (See below for
more information)
DOS_STDPKT When you want a "standard AmigaDOS
Packets".
DOS_CLI Object needed when you write
your own Shells.
DOS_RDARGS Used by the command line parsing
routines as described in chapter 5
"Parsing the Command Line".
tags: (struct TagItem *) Pointer to a list of one or more
TagItem structures which has been initialized with
your requirements, or NULL if you do not want to set
any tags.
This tag filed is currently only used when you write
your own file handlers or Shells. The available tags
are listed in header file "dos/dos.h", but since they
are rarely used with this function I have not listed
them here. As always the last "Tag ID" must be
"TAG_DONE".
Since this function uses the new "Tag Sytem" there exist two
other options on how to call the function:
Synopsis: object = AllocDosObjectTagList( type, tags );
This one is identical to the "AllocDosObject()" function
which we have just described. See above for information about
the arguments.
Synopsis: object = AllocDosObjectTags( type, tag1, tag2, ... );
Similar to "AllocDosObject()", but instead of giving the
function a pointer to a list of TagItem structures you list
all tags as arguments for the function. Note that the last
"Tag ID" must as always be "TAG_DONE".
tag1: (ULONG) The ID for tag 1.
tag2: (ULONG) The Data for tag 1.
tag3: (ULONG) The ID for tag 2.
- - - and so on...
tagX: (ULONG) The ID for tag X, must be "TAG_DONE".
Note! All objects which are allocated with help of the
AllocDosObject() function must when not needed any more be
deallocated with help of the FreeDosObject() function.
Here is a simple example on how to use the AllocDosObject()
function:
/* Declare a pointer to our FileInfoBlock */
/* which we will allocate: */
struct FileInfoBlock *my_fib;
- - -
/* Create a FileInfoBlock structure with help */
/* of the new AllocDosObject() function: */
my_fib = AllocDosObject( DOS_FIB, NULL );
/* Check if we have allocated the memory successfully: */
if( !my_fib )
printf( "Could not allocate the FileInfoBlock!\n" );
See also: Examine(), FreeDosObject()
---------------------------------------------------------------
Examine()
ROM library: "dos.library/Examine", (All versions)
#include <clib/dos_protos.h>
Examines a file, direcotry, volume (or device) and stores some
interesting information about the object in a given
FileInfoBlock structure.
Synopsis: ok = Examine( lock, fib );
ok: (LONG) If the function managed to examine the object
it returns "DOSTRUE". On the other hand, if the
function failed to get the information it returns
"DOSFALSE".
lock: (BPTR) A BCPL pointer to the lock on the object you
want to examine.
fib: (struct FileInfoBlock *) Pointer to a FileInfoBlock
structure in which all information will be stored.
This structure must be long word aligned.
Here is a simple example on how to use the Examine() function:
/* AmigaDOS boolean check variable: */
LONG ok;
- - -
/* Get some information about an object: */
ok = Examine( my_lock, my_fib );
/* Could we get the information? */
if( !ok )
printf( "Error! Could not examine the object!\n" );
else
printf( "OK! You may examine the FileInfoBlock structure" );
See also: AllocDosObject(), AllocMem(), ExNext(),
FreeDosObject()
---------------------------------------------------------------
ExNext()
ROM library: "dos.library/ExNext", (All versions)
#include <clib/dos_protos.h>
Examines objects in a directory, device, or volume. Can be
called several times until there are no more objects to
examine.
Synopsis: ok = ExNext( lock, fib );
ok: (LONG) If the function managed to examine the object
it returns "DOSTRUE". On the other hand, if the
function failed to get the information it returns
"DOSFALSE".
When this function fails you should call the IoErr()
function to get more information about the error. If
IoErr() returns "ERROR_NO_MORE_ENTRIES" there were
simply no more objects in the directory (device/
volume), but if IoErr() returns anything else there
was some sort of "real" error.
lock: (BPTR) A BCPL pointer to the lock you used when you
first called Examine().
fib: (struct FileInfoBlock *) Pointer to a FileInfoBlock
structure in which all information will be stored.
This structure must be long word aligned, and you
may not alter any of the fields while you are
collecting objects. You may only read the values,
not modify them!
After you have successfully examined a directory, device or
volume with help of the Examine() function you can use this
function to get information about the objects in that
directory, device or volume. To examine all objects simply
call this function over and over again until it fails because
there are no more objects left to examine, or there was some
sort of error.
Here is a simple example on how to use the ExNext() function:
(You must of course first have called the Examine() function
and checked that it really is a directory (device or volume)
before you may call ExNext().)
- - -
/* As long as we find objects we stay in the loop and */
/* prints the name of the objects we find: */
while( ExNext( my_lock, my_fib ) )
printf( "%s\n", my_fib->fib_FileName );
/* The ExNext() function has now failed. Check if it simply */
/* was no more objects left to examine or if there really */
/* was an error: */
if( IoErr() == ERROR_NO_MORE_ENTRIES )
printf( "OK! No more files!\n" );
else
printf("Error while reading!\n");
See also: Examine()
---------------------------------------------------------------
FreeDosObject()
ROM library: "dos.library/FreeDosObject", (V37+)
#include <clib/dos_protos.h>
Deallocates objects that was created by a previous call to the
AllocDosObject() function.
Synopsis: FreeDosObject( type, tags );
types: (ULONG) The type of object that should be
deallocated: (You must of course use the same type
as when you allocated the object. See function
AllocDosObject() for more information about the
available types.)
DOS_FIB
DOS_FILEHANDLE
DOS_EXALLCONTROL
DOS_STDPKT
DOS_CLI
DOS_RDARGS
object: (APTR) Pointer to the object that should be
deallocated.
Note! All objects which are allocated with help of the
AllocDosObject() function must when not needed any more be
deallocated with help of this FreeDosObject() function.
Note! Only objects which were created by AllocDosObject() may
be deallocated with this function.
Here is a simple example on how to use the FreeDosObject()
function:
- - -
/* Deallocate the FileInfoBlock structure wich we have */
/* created with help of the AllocDosObject() function: */
FreeDosObject( DOS_FIB, my_fib );
See also: AllocDosObject(), Examine()
---------------------------------------------------------------
Info()
ROM library: "dos.library/Info", (All versions)
#include <clib/dos_protos.h>
Examines a disk and stores some interesting information about
it in an InfoData structure.
Synopsis: ok = Info( lock, info );
ok: (LONG) If the function managed to examine the disk
it returns "DOSTRUE". On the other hand, if the
function failed to get the information it returns
"DOSFALSE".
lock: (BPTR) A BCPL pointer to a lock on the disk you want
to examine.
info: (struct InfoData *) Pointer to an InfoData structure
which will be used to store all information in.
Please note that since you have to supply this
function with your own structure is must be long
word aligned!
Here is a simple example on how to use the Info() function:
/* If the function was successful or not: */
LONG ok;
- - -
/* Examine the disk: */
ok = Info( my_lock, my_info_data );
if( ok )
{
/* Print some info about the disk: */
if( my_info_data->id_DiskState == ID_WRITE_PROTECTED )
printf( "The disk is Write Protected!\n" );
if( my_info_data->id_DiskState == ID_VALIDATED )
printf( "The disk is Not (Write) Protected!\n" );
}
else
printf( "Could not examine the disk!\n" );
See also: AllocMem(), Lock()
---------------------------------------------------------------